<?php
/**
 * @copyright        2016 opencart.cn - All Rights Reserved
 * @link             http://www.guangdawangluo.com
 * @author           TL <mengwb@opencart.cn>
 * @created          2016-11-23 11:12:00
 * @modified         2016-11-23 15:11:10
 */

function curlPost($url, $data, $xml = false) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    if ($xml) {
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type'=>'text/xml'));
    }

    $output = curl_exec($ch);
    curl_close($ch);

    return $output;
}

function curlGet($url, $data) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url . http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);

    $output = curl_exec($ch);
    curl_close($ch);

    return $output;
}
